<template>
  <div>
    <div class="box">
      <div v-for="(item, index) in list" :key="index">
        <input type="checkbox" v-model="hobby" :value="item" />{{ item }}
      </div>
    </div>
    <div>
      <ul>
        <li>
          选中的元素累加和为：<span>{{ total() }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      list: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      hobby: []
    }
  },
  methods: {
    total () {
     return this.hobby.reduce((a, c) => a + c, 0)
    }
  }
}
</script>

<style>
.box {
  display: flex;
}
</style>
